package com.atguigu.mapper.impl;

import com.atguigu.mapper.UserMapper;
import com.atguigu.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @Author: liuaojun
 * @CreateTime: 2025-01-20
 * @Description:
 * @Version: 1.0
 */
@Repository
public class UserMapperImpl implements UserMapper {

    @Autowired
    private JdbcTemplate jdbcTemplate;

    @Override
    public void addUser(User user) {
        String sql="insert into t_user(username,password,nickname) values(?,?,?)";
        jdbcTemplate.update(sql,user.getUsername(),user.getPassword(),user.getNickname());
    }

    @Override
    public void updateUser(User user) {
        String sql="update t_user set username=?,password=?,nickname=? where id=?";
        jdbcTemplate.update(sql,user.getUsername(),user.getPassword(),user.getNickname(),user.getId());
    }

    @Override
    public User findUserById(int id) {
        return null;
    }

    @Override
    public List<User> findUser() {
        return List.of();
    }

    @Override
    public void deleteUserById(int id) {

    }

}
